<template>
	<view>
		<cu-custom bgColor="bg-blue"  :isBack="true"><block slot="content">报告详情</block></cu-custom>
		<view class="cu-bar bg-white solid-bottom">
			<view class="action">
				<text class="cuIcon-titles text-blue"></text> 基本信息
			</view>
		</view>
		<view class="margin-sm">
			<view class="cu-form-group">
				<view class="title">姓名</view>
				<view class="text-right">{{order.submitName}}</view>
			</view>
			<view class="cu-form-group">
				<view class="title">手机号</view>
				<view class="text-right">{{order.submitPhone}}</view>
			</view>
			<view class="cu-form-group"   @tap="showDatePicker">
				<view class="title">送检日期</view>
				<view class="basis-regin text-right">{{order.submitDate}}</view>
			</view>
			<view class="cu-form-group"  @tap="showRegionPicker">
				<view class="title">接收城市</view>
				<view class="basis-regin text-right">{{order.acceptRegName}}</view>
			</view>
			<view class="cu-form-group" @tap="acceptUserShow">
				<view class="title">接收员</view>
				<view class="basis-regin text-right">{{order.acceptUserName}}</view>
			</view>
		</view>
		
		<view class="cu-bar bg-white solid-bottom">
			<view class="action">
				<text class="cuIcon-titles text-blue"></text> 样品列表
			</view>
		</view>
		<view class="margin-sm margin-bottom-xl padding-bottom-xl">
			<view v-for="(item,index) in order.orderDetail" :key="index" class="margin-bottom-sm">
				<view class="cu-form-group" @click="simpleTypeShow(index)">
					<view class="title">样品种类</view>
					<view class="basis-regin text-right">
						{{item.simpleTypeName}}
					</view>
				</view>
				<view class="cu-form-group">
					<view class="title">样品编号</view>
					<view class="basis-regin text-right">
						<text>{{item.orderNumber}}</text>
					</view>
				</view>
				<view class="cu-form-group">
					<view class="title">检测指标</view>
					<view class="basis-regin text-right">
						<text>{{item.norm}}</text>
					</view>
				</view>
				
				<view class="cu-form-group">
					<view class="title">原始编码</view>
					<view class="basis-regin text-right">
						<text>{{item.originalCode?item.originalCode:""}}</text>
					</view>
				</view>
				<view class="cu-form-group">
					<view class="title">状态(
						<text v-if="item.state==10" class="text-red">未受理</text>
						<text v-if="item.state==20" class="text-blue">已受理</text>
						<text v-if="item.state==30" class="text-green">已生成</text>
						<text v-if="item.state==40" class="text-orange">已复核</text>
						<text v-if="item.state==50" class="text-orange">已付款</text>
					)</view>
					<view v-if="order.delFlag>3&&item.state>20" class="basis-regin text-right ">
						<button class="cu-btn bg-green shadow-blur sm" @tap="goOrderDtailReport(item)">样品报告</button>
					</view>
				</view>
			</view>
		</view>
		<view class="cu-bar tabbar bg-white shadow foot">
			<view class="cu-bar btn-group">
				<button v-if="order.delFlag==3" class="cu-btn  bg-green shadow" @tap="acceptOrderChange">受理</button>
				<button v-else-if="order.delFlag==7" class="cu-btn  bg-green shadow" @tap="payedOrderChange">已付款</button>
				<view v-else class="text-green shadow">已受理</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { getOrder,acceptOrder} from '@/api/modules/order.js'
	export default {
		name:"acceptOrderDetail",
		data() {
			return {
				orderId:"",
				order:{}
			}
		},
		onLoad(options) {
			this.orderId=options.orderId
		},
		onShow() {
			this.getOrderDetail()
		},
		methods: {
			getOrderDetail(){
				let self=this
				getOrder(this.orderId).then(res=>{
					if(res.data.code==200){
						console.log(res.data.data)
						self.order=res.data.data
					}
				})
			},
			//受理
			acceptOrderChange(){
				let self=this
				let data={
					orderId:this.orderId,
					delFlag:5// 受理
				}
				acceptOrder(data).then(res=>{
					if(res.data.code==200){
						uni.showToast({
							title:"受理成功"
						})
						self.getOrderDetail()
					}
				})
			},
			//已付款
			payedOrderChange(){
				let self=this
				let data={
					orderId:this.orderId,
					delFlag:9// 已付款
				}
				acceptOrder(data).then(res=>{
					if(res.data.code==200){
						uni.showToast({
							title:"已付款成功"
						})
						self.getOrderDetail()
					}
				})
			},
			//生成样品报告
			goOrderDtailReport(item){
				uni.navigateTo({
					url:"../acceptOrderDetailReport/acceptOrderDetailReport?orderDetailId="+item.orderDetailId
				})
			}
			
		}
	}
</script>

<style>
page{
	background-color: #f0f0f0;
}
</style>
